﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Practice_02
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            comboBox1.Items.Add("+");
            comboBox1.Items.Add("-");
            comboBox1.Items.Add("*");
            comboBox1.Items.Add("/");
           
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            MessageBox.Show("你选择的运算符为：" + comboBox1.Text);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            double op1 = double.Parse(textBox1.Text);
            double op2 = double.Parse(textBox2.Text);
            String op3 = comboBox1.Text;
            double result = 0;
            switch (op3)
            {
                case "+":
                    result = op1 + op2;
                    break;
                case "-":
                    result = op1 - op2;
                    break;
                case "*":
                    result = op1 * op2;
                    break;
                case "/":
                    result = op1 / op2;
                    break;
                    
            }
            String result_e = Convert.ToString(result);
            MessageBox.Show("最终运算结果为："+result_e);

        }
    }
}
